package com.lf.web.config;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by LF on 2017/5/8.
 */
@ControllerAdvice
public class MyExceptionHandlerAdvice {

    @ExceptionHandler
    public String exp(HttpServletRequest request, Exception ex) {
        request.setAttribute("ex", ex);
        // 根据不同错误转向不同页面
        if (ex instanceof Exception) {
            return "business_error";
        }
        return "index";
    }
}
